$(function () {
    //表格初始化
    $("#cus_grid").datagrid({
        /*自适应*/
        fit: true,
        /*向此地址发送请求获得数据填充表格*/
        url: '/faillog/query.do?state=false',
        columns: [/*此处为第一层列标题*/[
            {field: "date", title: "确认失败时间", width: 100},
            {field: "cus", title: "客户名称", width: 100,formatter:function (value) {
                return value? value.name :"";
            }},
            {field: "cus_sn", title: "客户编号", width: 100,formatter:function (value,row) {
                return row.cus ? row.cus.sn : ""
            }},
            {field: "charge", title: "原客户负责人", width: 100,formatter:function (value) {
                return value ? value.username : ""
            }},
            {field: "text", title: "客户开发失败原因", width: 200},

        ]/*此处可以插入第二层标题*/],
        //为表格顶端的按键
        toolbar: "#tb",
        //真正的自动展开收缩列的大小,以适应网格的宽度,防水平滚动
        fitColumns: true,
        //可在行底显示分页工具栏
        pagination: true,
        //行码
        rownumbers: true,
        //只允许单选某行
        singleSelect: true,
    })
})
//看用户编码
function query() {
    var startDate = $("[name=startDate]").val();
    var endDate = $("[name=endDate]").val();
    var customer = $("[name=customer]").val();
    var charge = $("[name=charge]").val();
    $("#cus_grid").datagrid('load', {
        startDate: startDate,
        endDate:endDate,
        customer:customer,
        charge:charge,
    })
}
function reload(){
    $("#cus_grid").datagrid("reload");
}
function reset(){
    $.messager.confirm("提示信息","请问您是否确认重置查询条件",function (a) {
        if (a){
            $(".qeury_date_text").datebox("setValue","");
            $(".qeury_text").textbox("clear");
            query();
        }else{
            return;
        }
    })

}